﻿Namespace Muhasebe.Odeme
	Module Functions

		Function KisiKurumOku(ByVal Process As Token, ByVal rowid As Integer) As Recordset
			Return Process.OpenSQL("select * from muhasebe.dbo.kurum where rowid = @rowid", rowid)
		End Function

		Sub KisiKurumKaydet(ByVal Token As Token, ByVal rowid As Integer, ByVal adi As String, ByVal odemeyeri As Integer, ByVal hesapno As String)
			Dim Rs As Recordset = KisiKurumOku(Token, rowid)
			If Rs.EOF Then Rs.AddNew()
			Rs.SetValues("adi,odemeyeri,hesapno", adi, odemeyeri, hesapno)
			Rs.Save()
		End Sub

		Function KurumSource() As String
			Return "q@select rowid as kod,adi as ad from muhasebe..kurum order by adi"
		End Function

		Sub Kaydet(ByVal Token As Token, ByVal kurum As Integer, ByVal tarih As Date, ByVal tutar As Decimal, ByVal aciklama As String)
			Dim Rs As Recordset = Token.OpenSQL("select * from muhasebe.dbo.odeme where rowid = 0")
			Rs.AddNew()
			Rs.SetValues("kime,giristar,tutar,aciklama", kurum, tarih, tutar, aciklama)
			Rs.Save()
		End Sub

		Function Liste(Token As Token, d1 As Date, d2 As Date) As Recordset
			Q("select tarih,eno,alacakli,odemik,case when isnull(onay,'') = '1' then 'E' else 'H' end as onay,islemtar,kaykul")
			Q("from muhasebe..odemeemri where tarih between @d1 and @d2")
			Return Token.OpenSQL("*", d1, d2)
		End Function

	End Module
End Namespace
